<!DOCTYPE html>
<html>
<head> 
<meta charset="utf-8"> 
<title>2024版1D&1H价格计算公式</title> 
<style>
    body {
        background-color:#efefef;
        padding: 20px;
    }
    
    p {
        font-family:"Times New Roman";
        font-size:13px;
    }
    dt {
        font-family:"Times New Roman";
        font-size:15px;
        font-weight: bold;
        margin: 20px;
    }
    li {
        font-family:"Times New Roman";
        font-size:16px;
        font-weight: bold;
    }
    .priceLab {
        width: 200px;
    }
    </style>
</head>
<body>
    <h3>结果</h3>
<ul>
    <li><font id="rs" color="green"></font></li>
    <li><font id="rs1" color="orange"></font></li>
    <li><font id="rs2" color="blue"></font></li>
    <li><font id="rs3" color="green"></font></li>
</ul>
<h3>数据</h3>
<form name="btcForm">
    <dl>
        <dt>级别</dt>
        <dd>
            <input type="radio" name="level" id="1h" value="1" checked>
            <label for="1h">1H</label>
            <input type="radio" name="level" id="1d" value="0">
            <label for="1d">1D</label>
        </dd>
        <dt>信号方向</dt>
        <dd>
            <input type="radio" name="type" id="gold" value="1" checked>
            <label for="gold">做多</label>
            <input type="radio" name="type" id="dead" value="0">
            <label for="dead">做空</label>
        </dd>
        <dt>信号价格</dt>
        <dd>
            <input type="text" name="price" id="pc" value="0"><br>
        </dd>
        <dt>杠杆</dt>
        <dd>
            <input type="text" name="lever" value="12">倍<br>
        </dd>
</dl>
<input type="button" value="提交" onclick="javascript:submitFunc();">
</form>

    <script>
        function submitFunc() {
            var form = document.btcForm;
            var level = parseInt(form.level.value);
            var type = parseInt(form.type.value);
            var price = form.price.value;
            var lever = form.lever.value;
            var ms = "", ms1 = "", ms2 = "", ms3 = "";
            var stopPrice = 0;//止损价
            if (level == 1) {
                // 1小时              
                if (type == 1) {
                    stopPrice = (price * 1.02).toFixed(2);//多止损2%
                    rs.color = "green";
                    ms = "【1小时】，"+lever+"倍，做多";
                    ms1 = " 0.0%：" + price + "，止损-1.0%：" + (price * (1-0.01)).toFixed(2);
                    // 1%信号
                    ms1 += "\r 1.0%："+ (price * (1+0.01)).toFixed(2) +"，止损-1%：" + (price * (1-0.01)).toFixed(2);
                    // 2%信号
                    ms1 += "\r 2.0%："+ (price * (1+0.02)).toFixed(2) +"，止损0.5%：" + (price * (1+0.005)).toFixed(2);
                    
                    // 开仓3%
                    ms2 = "3.0%：" + (price * 1.03).toFixed(2) + "，止损2.0%：" + stopPrice + "，开仓"+lever + "倍" ;                   
                    // 4%
                    ms2 += "\r 4.0%："+ (price * (1+0.04)).toFixed(2)+"，止损2.4%：" + (price * (1+0.024)).toFixed(2);
                
                    // 5%
                    ms3 = "5.0%："+ (price * (1+0.05)).toFixed(2)+"，止平3%：" + (price * (1+0.03)).toFixed(2);
                    // 6%
                    ms3 += "\r 6.0%："+ (price * (1+0.06)).toFixed(2)+"，止平3.3%：" + (price * (1+0.033)).toFixed(2);
                    // 7%
                    ms3 += "\r 7.0%："+ (price * (1+0.07)).toFixed(2)+"，止赢4.1%：" + (price * (1+0.041)).toFixed(2) + "，加仓"+(lever/6).toFixed(2) + "倍";
                    // 8%
                    ms3 += "\r 8.0%："+ (price * (1+0.08)).toFixed(2)+"，止赢4.1%：" + (price * (1+0.041)).toFixed(2);
                    // 9%
                    ms3 += "\r 9.0%："+ (price * (1+0.09)).toFixed(2)+"，止赢4.1%：" + (price * (1+0.041)).toFixed(2);
                    // 10%
                    ms3 += "\r 10%："+ (price * (1+0.1)).toFixed(2)+"，止赢5.3%：" + (price * (1+0.05)).toFixed(2); 
                    ms3 += "\r 15%："+ (price * (1+0.15)).toFixed(2)+"，止赢10%：" + (price * (1+0.1)).toFixed(2); 
                    ms3 += "\r 18%：" + (price * (1+0.18)).toFixed(2)+"，止赢10%：" + (price * (1+0.1)).toFixed(2)+ "，加仓"+(lever/12).toFixed(2) + "倍";                   
                    // 20%
                    ms3 += "\r 20%："+ (price * (1+0.2)).toFixed(2)+"，25%："+ (price * (1+0.25)).toFixed(2)+"，28%："+ (price * (1+0.28)).toFixed(2)+"，止赢10%：" + (price * (1+0.1)).toFixed(2);              
                    // 30%
                    ms3 += "\r 30%："+ (price * (1+0.3)).toFixed(2)+"，33%："+ (price * (1+0.33)).toFixed(2)+"，38%："+ (price * (1+0.38)).toFixed(2)+"，止赢15%：" + (price * (1+0.15)).toFixed(2);               
                    // 40%
                    ms3 += "\r 40%："+ (price * (1+0.4)).toFixed(2)+"，43%："+ (price * (1+0.43)).toFixed(2)+"，48%："+ (price * (1+0.48)).toFixed(2)+"，止赢20%：" + (price * (1+0.2)).toFixed(2);              
                    // 50%
                    ms3 += "\r 50%："+ (price * (1+0.5)).toFixed(2)+"，53%："+ (price * (1+0.53)).toFixed(2)+"，58%："+ (price * (1+0.58)).toFixed(2)+"，止赢25%：" + (price * (1+0.25)).toFixed(2);
                    // 60%
                    ms3 += "\r 60%："+ (price * (1+0.6)).toFixed(2)+"，63%："+ (price * (1+0.63)).toFixed(2)+"，68%："+ (price * (1+0.68)).toFixed(2)+"，止赢30%：" + (price * (1+0.3)).toFixed(2);
                    // 70%
                    ms3 += "\r 70%："+ (price * (1+0.7)).toFixed(2)+"，73%："+ (price * (1+0.73)).toFixed(2)+"，78%："+ (price * (1+0.78)).toFixed(2)+"，止赢35%：" + (price * (1+0.35)).toFixed(2);
                    // 80%
                    ms3 += "\r 80%："+ (price * (1+0.8)).toFixed(2)+"，83%："+ (price * (1+0.83)).toFixed(2)+"，88%："+ (price * (1+0.88)).toFixed(2)+"，止赢40%：" + (price * (1+0.4)).toFixed(2);
                    // 90%
                    ms3 += "\r 90%："+ (price * (1+0.9)).toFixed(2)+"，93%："+ (price * (1+0.93)).toFixed(2)+"，98%："+ (price * (1+0.98)).toFixed(2)+"，止赢45%：" + (price * (1+0.45)).toFixed(2);
                    // 100%
                    ms3 += "\r 100%："+ (price * (1+1)).toFixed(2)+"，150%："+ (price * (1+1.5)).toFixed(2);
                    ms3 += "\r 200%："+ (price * (1+2)).toFixed(2)+"，250%："+ (price * (1+2.5)).toFixed(2);
                    ms3 += "\r 300%："+ (price * (1+3)).toFixed(2)+"，350%："+ (price * (1+3.5)).toFixed(2);
                    ms3 += "\r 400%："+ (price * (1+4)).toFixed(2)+"，450%："+ (price * (1+4.5)).toFixed(2);
                    ms3 += "\r 500%："+ (price * (1+5)).toFixed(2);
                } else {
                    stopPrice = (price * 0.99).toFixed(2);//空止损1%
                    rs.color = "red";
                    ms = "【1小时】，"+lever+"倍，做空";
                    ms1 = " 0%："+ price +"，止损-1%，" + (price * (1+0.01)).toFixed(2);
                    // 1%盈利止盈
                    ms1 += "\r 1%："+ (price * (1-0.01)).toFixed(2) +"，止损-1%，" + (price * (1+0.01)).toFixed(2);
                    // 2%盈利止盈
                    ms1 += "\r 2%："+ (price * (1-0.02)).toFixed(2) +"，止损0.6%，" + (price * (1-0.006)).toFixed(2);
                
                    // 开仓3%
                    ms2 = "信号3%，" + lever + "倍，" + (price * 0.97).toFixed(2) + " 开仓；止损2% " + (price * (1-0.02)).toFixed(2) ;
                    // 4%信号
                    ms2 += "\r 4%："+ (price * (1-0.04)).toFixed(2)+"，止损2.3%，" + (price * (1-0.023)).toFixed(2);
                
                
                // 5%盈利止盈
                ms3 = "5%："+ (price * (1-0.05)).toFixed(2)+"，止平3.2%，" + (price * (1-0.032)).toFixed(2);
                // 6%盈利止盈
                ms3 += "\r 6%："+ (price * (1-0.06)).toFixed(2)+"，止平3.2%，" + (price * (1-0.032)).toFixed(2);
                // 7%盈利止盈
                ms3 += "\r 7%："+ (price * (1-0.07)).toFixed(2)+"，止平3.4%，" + (price * (1-0.034)).toFixed(2);
                // 8%盈利止盈
                ms3 += "\r 8%："+ (price * (1-0.08)).toFixed(2)+"，止平3.8%，" + (price * (1-0.038)).toFixed(2);
                // 9%盈利止盈
                ms3 += "\r 9%："+ (price * (1-0.09)).toFixed(2)+"，止赢4.3%，" + (price * (1-0.043)).toFixed(2);
                // 10%盈利止盈
                ms3 += "\r 10%："+ (price * (1-0.1)).toFixed(2)+"，止赢4.3%，" + (price * (1-0.043)).toFixed(2);
                ms3 += "\r 15%："+ (price * (1-0.15)).toFixed(2)+"，止赢8%，" + (price * (1-0.08)).toFixed(2);
                // 18%盈利止盈
                ms3 += "\r 18%：" + (lever/12).toFixed(2) + "倍，"+ (price * (1-0.18)).toFixed(2)+"，止赢8%，" + (price * (1-0.08)).toFixed(2);
                // 20%盈利止盈
                ms3 += "\r 20%："+ (price * (1-0.2)).toFixed(2)+"，止赢10%，" + (price * (1-0.1)).toFixed(2);
                // 28%盈利止盈
                ms3 += "\r 28%："+ (price * (1-0.28)).toFixed(2)+"，止赢10%，" + (price * (1-0.1)).toFixed(2);
                // 30%盈利止盈
                ms3 += "\r 30%："+ (price * (1-0.3)).toFixed(2)+"，止赢15%，" + (price * (1-0.15)).toFixed(2);
                // 33%加仓
                ms3 += "\r 33%："+ (price * (1-0.33)).toFixed(2)+"，止赢15%，" + (price * (1-0.15)).toFixed(2);
                // 38%盈利止盈
                ms3 += "\r 38%："+ (price * (1-0.38)).toFixed(2)+"，止赢15%，" + (price * (1-0.15)).toFixed(2);
                // 40%盈利止盈
                ms3 += "\r 40%："+ (price * (1-0.4)).toFixed(2)+"，止赢20%，" + (price * (1-0.2)).toFixed(2);
                // 43%加仓
                ms3 += "\r 43%："+ (price * (1-0.43)).toFixed(2)+"，止赢20%，" + (price * (1-0.2)).toFixed(2);
                // 50%盈利止盈
                ms3 += "\r 50%："+ (price * (1-0.5)).toFixed(2);
                // 55%加仓
                ms3 += "\r 55%："+ (price * (1-0.55)).toFixed(2);
                // 60%盈利止盈
                ms3 += "\r 60%："+ (price * (1-0.6)).toFixed(2);
                // 65%加仓
                ms3 += "\r 65%："+ (price * (1-0.65)).toFixed(2);
                // 80%盈利止盈
                ms3 += "\r 80%："+ (price * (1-0.8)).toFixed(2);
                // 100%盈利止盈
                    ms3 += "\r 100%：无法计算";
                }
                
            } else {
                // 日线
                ms = "--日线--";
                if (type == 1) {
                    ms += "\r 信号0%， " + price + " 做多；建议止损-7%， " + (price * (1-0.07)).toFixed(2) + "； 杠杆 x" + lever;
                    // 10%盈利止盈1%
                    ms2 = "10%："+ (price * (1+0.1)).toFixed(2)+"，止赢1%，" + (price * (1+0.01)).toFixed(2);
                    // 20%盈利止盈14%
                    ms2 += "\r 20%："+ (price * (1+0.2)).toFixed(2)+"，止赢10%，" + (price * (1+0.1)).toFixed(2);
                    // 27%盈利加入MA60日线止盈
                    ms2 += "\r 27%："+ (price * (1+0.27)).toFixed(2)+"，加入MA60日线止盈";
                    // 30%盈利止盈14%
                    ms2 += "\r 30%："+ (price * (1+0.3)).toFixed(2)+"，止赢20%，" + (price * (1+0.2)).toFixed(2);
                    // 40%盈利止盈28%
                    ms2 += "\r 40%："+ (price * (1+0.4)).toFixed(2)+"，止赢27%，" + (price * (1+0.27)).toFixed(2);
                    // 50%盈利止盈35%
                    ms2 += "\r 50%："+ (price * (1+0.5)).toFixed(2)+"，止赢35%，" + (price * (1+0.35)).toFixed(2);
                    // 60%盈利止盈38%
                    ms2 += "\r 60%："+ (price * (1+0.6)).toFixed(2)+"，止赢38%，" + (price * (1+0.38)).toFixed(2);
                    // 70%盈利止盈45%
                    ms2 += "\r 70%："+ (price * (1+0.7)).toFixed(2)+"，止赢45%，" + (price * (1+0.45)).toFixed(2);
                    // 80%盈利止盈48%
                    ms2 += "\r 80%："+ (price * (1+0.8)).toFixed(2)+"，止赢48%，" + (price * (1+0.48)).toFixed(2);
                    // 90%盈利止盈80%
                    ms2 += "\r 90%："+ (price * (1+0.9)).toFixed(2)+"，止赢80%，" + (price * (1+0.80)).toFixed(2);
                    // 100%盈利止盈90%
                    ms2 += "\r 100%："+ (price * (1+1)).toFixed(2)+"，止赢90%，" + (price * (1+0.90)).toFixed(2);
                    // 120%盈利止盈100%
                    ms2 += "\r 120%："+ (price * (1+1.2)).toFixed(2)+"，止赢100%，" + (price * (1+1)).toFixed(2);
                    // 150%盈利止盈130%
                    ms2 += "\r 150%："+ (price * (1+1.5)).toFixed(2)+"，止赢130%，" + (price * (1+1.3)).toFixed(2);
                    // 180%盈利止盈150%
                    ms2 += "\r 180%："+ (price * (1+1.8)).toFixed(2)+"，止赢150%，" + (price * (1+1.5)).toFixed(2);
                    // 200%盈利止盈
                    ms2 += "\r 200%："+ (price * (1+2)).toFixed(2)+"，止赢MA60日线";
                } else {
                    ms += "\r 信号0%， " + price + " 做空；建议止损-6%， " + (price * (1+0.06)).toFixed(2) + "； 杠杆 x" + lever;
                    // 10%盈利止盈4%
                    ms2 = "10%："+ (price * (1-0.1)).toFixed(2)+"，止赢4%，" + (price * (1-0.04)).toFixed(2);
                    // 20%盈利止盈10%
                    ms2 += "\r 20%："+ (price * (1-0.2)).toFixed(2)+"，止赢10%，" + (price * (1-0.1)).toFixed(2);
                    // 30%盈利止盈18%
                    ms2 += "\r 30%："+ (price * (1-0.3)).toFixed(2)+"，止赢20%，" + (price * (1-0.2)).toFixed(2);
                    // 32%盈利加入MA60日线止盈
                    ms2 += "\r 32%："+ (price * (1-0.32)).toFixed(2)+"，加入MA60日线止盈";
                    // 40%盈利止盈28%
                    ms2 += "\r 40%："+ (price * (1-0.4)).toFixed(2)+"，止赢33%，" + (price * (1-0.33)).toFixed(2);
                    // 50%盈利止盈42%
                    ms2 += "\r 50%："+ (price * (1-0.5)).toFixed(2)+"，止赢42%，" + (price * (1-0.42)).toFixed(2);
                    // 60%盈利止盈38%
                    ms2 += "\r 60%："+ (price * (1-0.6)).toFixed(2)+"，止赢MA60日线" ;
                }
            }
            rs.innerText = ms;
            rs1.innerText = ms1;
            rs2.innerText =  ms2;
            rs3.innerText =  ms3;
        }
    </script>
</body>
</html>